<!--
 * @Author: quit
 * @Date: 2021-11-15 04:42:40
 * @LastEditTime: 2021-11-18 10:34:17
 * @Descripttion: 语言切换组件
-->
<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <div>
      <svg-icon icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh_CN" :disabled="'zh_CN' === $i18n.locale">中文</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="'en' === $i18n.locale">EN</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  // inject: ['reload'],
  methods: {
    changeLanguage(lang) {
      Cookie.set('language', lang) // 切换多语言
      this.$i18n.locale = lang // 设置给本地的i18n插件
      // this.reload()
    }
  }
}
</script>
